﻿// INGENIOUS FRAMEWORK - Semantic Web Development Simplified
// Copyright (C) 2012 Linked Data Tools

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ingenious.Owl
{
    #region OWL Thing
    /// <summary>
    /// The subclass of all OWL classes
    /// </summary>
    public class OwlThing { }

    /// <summary>
    /// The superclass of all OWL classes
    /// </summary>
    public class OwlNothing { }
    #endregion

    #region OWL Classes
    public class ClassAttribute : Attribute
    {
        private readonly Type m_ontologyType;
        private readonly Uri m_about;
        private readonly Type m_superClass;

        #region Object Lifetime
        public ClassAttribute(Type ontologyType, Uri about, Type superClass)
        {
            if (ontologyType == null)
            {
                throw new ArgumentNullException("ontologyType");
            }

            if (superClass == null)
            {
                throw new ArgumentNullException("superClass");
            }

            if (about == null)
            {
                throw new ArgumentNullException("about");
            }

            m_ontologyType = ontologyType;
            m_superClass = superClass;
            m_about = about;
        }

        public ClassAttribute(Type ontologyType, string id, Type superClass)
        {
            if (ontologyType == null)
            {
                throw new ArgumentNullException("ontologyType");
            }

            if (superClass == null)
            {
                throw new ArgumentNullException("superClass");
            }

            if (id == null)
            {
                throw new ArgumentNullException("id");
            }

            if (!id.StartsWith(OntologyHelper.HashPrefix))
            {
                id = OntologyHelper.HashPrefix + id;
            }

            m_ontologyType = ontologyType;
            m_superClass = superClass;
            m_about = new Uri(id, UriKind.Relative);
        }

        /// <summary>
        /// OWL class (absolute URI)
        /// </summary>
        /// <param name="ontologyType">Parent ontology type</param>
        /// <param name="about">Absolute URI of OWL class</param>
        public ClassAttribute(Type ontologyType, Uri about)
            : this(ontologyType, about, typeof(OwlThing))
        {
        }

        /// <summary>
        /// OWL class (relative URI)
        /// </summary>
        /// <param name="ontologyType"></param>
        /// <param name="id"></param>
        public ClassAttribute(Type ontologyType, string id)
            : this(ontologyType, id, typeof(OwlThing))
        {
        }
        #endregion

        #region Properties
        public Uri About
        {
            get { return m_about; }
        }
        #endregion
    }
    #endregion
}
